<?
$xajax = new xajax();

function myFunction($arg)
{
	global $set_table_prefix;
	$objResponse = new xajaxResponse();
	$lTableRegion=$set_table_prefix . "regions";
	
	$arg=trim($arg);
	if ($arg!="")
	{
		
		$lArgArray=split("\|",$arg);
		$arg=$lArgArray[0];
		$lSelected=$lArgArray[1];
		
    	$lIsLast=0;
    	$lNb=2; 
    	$lAddOn="_";
    	if (ereg("_",$arg))
    	{
    		$arg=ereg_replace("_","",$arg);
    		
    		$lIsLast=1;
    		$lNb=3;
    		$lAddOn="";
    	}
    	else 
    		$lSelected=ereg_replace("_","",$lSelected);
    	$lFormId="reg_$lNb";	    		
    	
    	if ($lNb==2) // Second level
    		$lReturn.="<select id='$lFormId' name='$lFormId' onChange='xajax_myFunction($lFormId.value)' class='regionselect'>";
    	else  // Third level
    		$lReturn.="<select id='$lFormId' name='$lFormId' class='regionselect'>";
    	$lReturn.="<option value=''>-- Select --</option>";
    	
    	$lItems=getRegionsForOneLevel($arg,$lSelected,$lAddOn);
		$lReturn.=$lItems . "</select>";
		
		if ($lItems=="")
			$lReturn=" ";
		
		$objResponse->addAssign("DropDown$lNb","innerHTML", "$lReturn");
	}
	return $objResponse;
	
}
$xajax->registerFunction("myFunction");
$xajax->processRequests();
?>